import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class term4 {
    public static void main(String[] args) {
        String inputFilePath = "source_code_file.txt"; // 文件路径
        List<String> extractedStrings = extractQuotedStrings(inputFilePath);
        for (String str : extractedStrings) {
            System.out.println(str);
        }
    }

    public static List<String> extractQuotedStrings(String inputFilePath) {
        List<String> resultStrings = new ArrayList<>();
        StringBuilder stringBuilder = new StringBuilder();
        boolean isInString = false;
        boolean isEscapeNext = false;

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath))) {
            int character;
            while ((character = reader.read()) != -1) {
                char currentChar = (char) character;

                if (isEscapeNext) {
                    // 如果上一个字符是反斜杠，则此字符将被添加到当前字符串
                    stringBuilder.append(currentChar);
                    isEscapeNext = false; // 重置状态
                } else {
                    switch (currentChar) {
                        case '"':
                            if (isInString) {
                                // 结束字符串
                                resultStrings.add(stringBuilder.toString());
                                stringBuilder.setLength(0); // 清空当前字符串
                                isInString = false; // 退出字符串状态
                            } else {
                                // 开始字符串
                                isInString = true;
                            }
                            break;
                        case '\\':
                            isEscapeNext = true; // 下一字符需要转义
                            break;
                        default:
                            if (isInString) {
                                stringBuilder.append(currentChar); // 在字符串内添加字符
                            }
                            break;
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return resultStrings;
    }
}